package mk.company.fin.frame.internal;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

import mk.company.fin.AppConstants;
import mk.company.fin.enums.NalogEntryType;
import mk.company.fin.model.Komintent;
import mk.company.fin.model.Konto;
import mk.company.fin.model.Nalog;
import mk.company.fin.model.NalogEntry;
import mk.company.fin.model.Organization;
import mk.company.fin.model.OrganizationSector;
import mk.company.fin.model.Year;
import mk.company.fin.service.KontoService;
import mk.company.fin.service.LocaleService;
import mk.company.fin.service.MessageService;
import mk.company.fin.service.ModelService;
import mk.company.fin.utils.ComboBoxElement;
import mk.company.fin.utils.ComboBoxElementRenderer;
import mk.company.fin.utils.StringEntry;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.context.ApplicationContext;

import com.toedter.calendar.JDateChooser;

public class FinansovNalogFrame extends AbstractInternalFrame{

	
	//component which this frame will be drawn
	JComponent component;
	public FinansovNalogFrame(JComponent component) {
		this.component=component;
		
	}
	
	public void draw() {
		injectServices();
		initComponents();
	}
	private static final long serialVersionUID = -9157999446785763615L;

	/* SERVICES */
	
	private MessageService messageService;
	private LocaleService localeService;
	private ModelService modelService;
	private KontoService kontoService;

	public void initialize(ApplicationContext context) {
		setContext(context);
		injectServices();
		// Defaults
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(new Dimension(AppConstants.MainFrame.WIDTH, AppConstants.MainFrame.HEIGHT));
		
		// components
		initComponents();
	}
	
	/**
	 * Inject services.
	 */
	private void injectServices() {
		messageService = getContext().getBean(MessageService.class);
		localeService=getContext().getBean(LocaleService.class);
		modelService=getContext().getBean(ModelService.class);
		kontoService=getContext().getBean(KontoService.class);
	}
	
	/**
	 * Initialize the components.
	 */
	
	
	//WarrantPanel
	private JPanel warrantPanel;
	private javax.swing.JLabel warrantYearLabel;
	private JTextField warrantYear;
	private javax.swing.JLabel warrantNumberLabel;
	private JTextField warrantNumberField;
	private javax.swing.JLabel warrantDateLabel;
	private JDateChooser warrantDate;
	private JLabel requiredLabelWarrant1;
	private JLabel requiredLabelWarrant2;
	private JLabel requiredLabelWarrant3;
	private JButton showEntriesButton;
	private void initWarrantPanel(){
		warrantPanel=new JPanel(new FlowLayout(FlowLayout.LEFT,10,0));
		warrantPanel.setBorder(BorderFactory.createTitledBorder(messageService.getMessage("warrant")));
		warrantYearLabel=new JLabel(messageService.getMessage("year")+":");
		warrantYear=new JTextField(4);
		warrantNumberLabel=new JLabel(messageService.getMessage("warrant")+":");
		warrantNumberField=new JTextField(10);
		warrantDateLabel=new JLabel(messageService.getMessage("warrant.date")+":");
		warrantDate=new JDateChooser();
		warrantDate.setLocale(localeService.getCurrentLocale());
		showEntriesButton=new JButton();
		showEntriesButton.setText(messageService.getMessage("warrant.show.entries"));
		showEntriesButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
		
				if (warrantYear.getText().equals("")){
					JOptionPane.showMessageDialog(component, messageService.getMessage("warrant.no.year"),"Error", JOptionPane.ERROR_MESSAGE);
					return;
				}
				if (warrantDate.getDate()==null){
					JOptionPane.showMessageDialog(component, messageService.getMessage("warrant.no.date"),"Error", JOptionPane.ERROR_MESSAGE);
					return;
				}
				if (warrantNumberField.getText().equals("")){
					JOptionPane.showMessageDialog(component, messageService.getMessage("warrant.no.number"),"Error", JOptionPane.ERROR_MESSAGE);
					return;
				}
				DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
				selectedNalog=getFilledNalog();
				try {
					// search properties
					List<StringEntry> properties = new ArrayList<StringEntry>(1);
					properties.add(new StringEntry("base.number", "'" + selectedNalog.getNumber()+ "'"));
					properties.add(new StringEntry("base.date", "'" + dateFormat.format(warrantDate.getDate())+"'"));
					
					// result
					List<Nalog> result = modelService.findByProperties(Nalog.class, null, properties);
					if (CollectionUtils.isEmpty(result)){
						modelService.update(selectedNalog);
					}
					else {
						selectedNalog=result.get(0);
					}
				}
				catch(Exception ex){
					System.out.println("Warrant cannot be added");
				}
//				warrantEntryPanel.setVisible(true);
				actionPanel.setVisible(true);
				warrantEntryTablePanel.setVisible(true);
				refreshTableData(selectedNalog);
				newWarrantNameField.setText(selectedNalog.getNumber());
			}
		
		});
		//Required Labels 
		requiredLabelWarrant1 = new javax.swing.JLabel();
		requiredLabelWarrant1.setForeground(new java.awt.Color(255, 0, 102));
		requiredLabelWarrant1.setText("*");
        requiredLabelWarrant2 = new javax.swing.JLabel();
        requiredLabelWarrant2.setForeground(new java.awt.Color(255, 0, 102));
        requiredLabelWarrant2.setText("*");
        requiredLabelWarrant3 = new javax.swing.JLabel();
        requiredLabelWarrant3.setForeground(new java.awt.Color(255, 0, 102));
        requiredLabelWarrant3.setText("*");
	}
	
	//WarrantEntryPanel
	private javax.swing.JPanel warrantEntryPanel;
	private javax.swing.JLabel debtDemandLabel;
	private javax.swing.JComboBox debtDemandComboBox;
	private javax.swing.JLabel amountLabel;
	private javax.swing.JTextField amountField;
	private javax.swing.JLabel documentTypeLabel;
	private javax.swing.JComboBox documentTypeComboBox;
	private javax.swing.JLabel documentDateLabel;
	private JDateChooser documentDate;
	private javax.swing.JLabel comintentLabel;
	private javax.swing.JComboBox comintentComboBox;
	private ComboBoxElementRenderer<Komintent> comintentComboBoxRenderer;
	private javax.swing.JLabel organizationSectorLabel; 
	private javax.swing.JComboBox organizationSectorComboBox;
	private ComboBoxElementRenderer<OrganizationSector> organizationSectorComboBoxRenderer;
	private javax.swing.JLabel accountLabel;
	private javax.swing.JTextField accountField;
	private javax.swing.JLabel descriptionLabel;
	private javax.swing.JTextField descriptionField;
	private javax.swing.JLabel documentNumberLabel;
	private javax.swing.JTextField documentNumberField;
	private javax.swing.JLabel currencyDateLabel;
	private JDateChooser currencyDateField;
	private javax.swing.JButton entryActionButton;
	private javax.swing.JLabel requiredLabel;
    private javax.swing.JLabel requiredLabel1;
    private javax.swing.JLabel requiredLabel2;
    private javax.swing.JLabel requiredLabel3;
    private Nalog selectedNalog;
    private List<OrganizationSector> organizationSectorList;
    private List<Komintent> komintentList;
	private void initWarrantEntryPanel(){
		warrantEntryPanel=new JPanel();
		warrantEntryPanel.setBorder(BorderFactory.createTitledBorder(messageService.getMessage("warrant.adding.entry")));
		debtDemandLabel=new JLabel(messageService.getMessage("warrant.entry.debt")+":");
		Vector<String> debtDemandComboBoxItems=new Vector<String>();
		debtDemandComboBoxItems.add(messageService.getMessage("warrant.debt"));
		debtDemandComboBoxItems.add(messageService.getMessage("warrant.demand"));
		debtDemandComboBox=new JComboBox(debtDemandComboBoxItems);
		amountLabel=new JLabel(messageService.getMessage("warrant.amount")+":");
		amountField=new JTextField(10);
		amountField.setText("0.0");
		documentTypeLabel=new JLabel(messageService.getMessage("warrant.document.type")+":");
		Vector<String> documentTypeComboBoxItems=new Vector<String>();
		documentTypeComboBoxItems.addElement("Type1");
		documentTypeComboBox=new JComboBox(documentTypeComboBoxItems);
		documentDateLabel=new JLabel(messageService.getMessage("warrant.document.date")+":");
		documentDate=new JDateChooser();
		documentDate.setLocale(localeService.getCurrentLocale());
		comintentLabel=new JLabel(messageService.getMessage("warrant.comintent")+":");
		komintentList=modelService.findAll(Komintent.class);
		Vector<ComboBoxElement<Komintent>> model=new Vector<ComboBoxElement<Komintent>>();
		for (Komintent komintent:komintentList){
			model.addElement(new ComboBoxElement<Komintent>(komintent, komintent.getName()+" "+komintent.getCode()));
		}
		comintentComboBox=new JComboBox(model);
		comintentComboBoxRenderer=new ComboBoxElementRenderer<Komintent>();
		comintentComboBox.setRenderer(comintentComboBoxRenderer);
		organizationSectorLabel=new JLabel(messageService.getMessage("warrant.organization.sector")+":");
		organizationSectorList=modelService.findAll(OrganizationSector.class);
		Vector<ComboBoxElement<OrganizationSector>> organizationSectorModel=new Vector<ComboBoxElement<OrganizationSector>>();
		for (OrganizationSector organizationSector:organizationSectorList){
			organizationSectorModel.addElement(new ComboBoxElement<OrganizationSector>(organizationSector, organizationSector.getCode()+" "+organizationSector.getDescription()));
		}
		organizationSectorComboBox=new JComboBox(organizationSectorModel);
		organizationSectorComboBoxRenderer=new ComboBoxElementRenderer<OrganizationSector>();
		organizationSectorComboBox.setRenderer(organizationSectorComboBoxRenderer);
		accountLabel=new JLabel(messageService.getMessage("warrant.account")+":");
		accountField=new JTextField(10);
		descriptionLabel=new JLabel(messageService.getMessage("warrant.description")+":");
		descriptionField=new JTextField(30);
		documentNumberLabel=new JLabel(messageService.getMessage("warrant.document.number")+":");
		documentNumberField=new JTextField(10);
		currencyDateLabel=new JLabel(messageService.getMessage("warrant.currency")+":");
		currencyDateField=new JDateChooser();
		currencyDateField.setLocale(localeService.getCurrentLocale());
		entryActionButton=new JButton();
		entryActionButton.setText(messageService.getMessage("warrant.add.entry"));
		entryActionButton.addActionListener(new ActionListener() {
			@SuppressWarnings("unchecked")
			@Override
			public void actionPerformed(ActionEvent arg0) {
				if (amountField.getText().equals("")){
					JOptionPane.showMessageDialog(component, messageService.getMessage("nalog.entry.no.amount"),"Error", JOptionPane.ERROR_MESSAGE);
					return;
				}
				try{
					Double.parseDouble(amountField.getText());
				}
				catch (Exception ex){
					JOptionPane.showMessageDialog(component, messageService.getMessage("nalog.entry.wrong.ammount"),"Error", JOptionPane.ERROR_MESSAGE);
					return;
				}
				if (((ComboBoxElement<Komintent>)comintentComboBox.getSelectedItem())==null){
					JOptionPane.showMessageDialog(component, messageService.getMessage("nalog.entry.no.comintent"),"Error", JOptionPane.ERROR_MESSAGE);
					return;
				}
				if (accountField.getText().equals("")){
					JOptionPane.showMessageDialog(component, messageService.getMessage("nalog.entry.no.account"),"Error", JOptionPane.ERROR_MESSAGE);
					return;
				}
				if (accountField.getText().length()<4){
					JOptionPane.showMessageDialog(component, messageService.getMessage("nalog.entry.not.valid.account"),"Error", JOptionPane.ERROR_MESSAGE);
					return;
				}
				String kontoClass=accountField.getText().substring(0,1);
				String kontoGroup=accountField.getText().substring(1,2);
				String kontoSynthetic=accountField.getText().substring(2,3);
				String kontoAnalytic=accountField.getText().substring(3,accountField.getText().length());
				if (kontoService.findKonto(kontoClass, kontoGroup, kontoSynthetic, kontoAnalytic)==null) {
					JOptionPane.showMessageDialog(component, messageService.getMessage("nalog.entry.not.existent.account"),"Error", JOptionPane.ERROR_MESSAGE);
					return;
				}
				if (entryActionButton.getText().equals(messageService.getMessage("organization.sector.action.add"))){
					
					try {
						NalogEntry nalogEntry=getFilledNalogEntry(selectedNalog);
						modelService.update(nalogEntry);
						clearData();
						refreshTableData(selectedNalog);
						warrantEntryPanel.setVisible(false);
					}
					catch (Exception ex){
						JOptionPane.showMessageDialog(component, messageService.getMessage("nalog.entry.error.save"),"Error", JOptionPane.ERROR_MESSAGE);
						return;
					}
				}
				if (entryActionButton.getText().equals(messageService.getMessage("organiazation.sector.action.save"))){
					try {
						NalogEntry nalogEntry=getFilledNalogEntry(selectedNalog);
						nalogEntry.setId(selectedNalogEntry.getId());
						modelService.update(nalogEntry);
						clearData();
						refreshTableData(selectedNalog);
						warrantEntryPanel.setVisible(false);
					}
					catch (Exception ex){
						JOptionPane.showMessageDialog(component, messageService.getMessage("nalog.entry.error.save"),"Error", JOptionPane.ERROR_MESSAGE);
						modelService.refresh(selectedNalog);
						return;
					}
				}
					
				
			}
				
			
		});

		//Required Labels
		requiredLabel = new javax.swing.JLabel();
		requiredLabel.setForeground(new java.awt.Color(255, 0, 102));
		requiredLabel.setText("*");
		requiredLabel1 = new javax.swing.JLabel();
		requiredLabel1.setForeground(new java.awt.Color(255, 0, 102));
		requiredLabel1.setText("*");
		requiredLabel2 = new javax.swing.JLabel();
		requiredLabel2.setForeground(new java.awt.Color(255, 0, 102));
		requiredLabel2.setText("*");
		requiredLabel3 = new javax.swing.JLabel();
		requiredLabel3.setForeground(new java.awt.Color(255, 0, 102));
		requiredLabel3.setText("*");
	}
	
	

	private javax.swing.JPanel actionPanel;
	private javax.swing.JButton addEntryButton;
	private javax.swing.JButton modifyEntryButton;
	private NalogEntry selectedNalogEntry;
	private javax.swing.JButton changeWarrantNameButton;
	private javax.swing.JTextField newWarrantNameField;
    private javax.swing.JLabel newWarrantNameLabel;
	private void initActionPanel(){
		actionPanel=new JPanel();
		actionPanel.setBorder(BorderFactory.createTitledBorder(messageService.getMessage("organization.sector.action")));
		addEntryButton=new JButton();
		addEntryButton.setText(messageService.getMessage("warrant.adding.entry"));
		modifyEntryButton=new JButton();
		modifyEntryButton.setText(messageService.getMessage("warrant.entry.modify"));
		newWarrantNameLabel=new JLabel(messageService.getMessage("warrant.new.name"));
		newWarrantNameField=new JTextField();
		newWarrantNameField.setColumns(7);
		
		changeWarrantNameButton=new JButton();
		changeWarrantNameButton.setText(messageService.getMessage("warant.change.name"));
		addEntryButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				entryActionButton.setText(messageService.getMessage("organization.sector.action.add"));
				warrantEntryPanel.setVisible(true);
				clearData();
			}
		});
		
		modifyEntryButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				if (warrantEntryTable.getSelectedRow()>=0){
					int rowIndex=warrantEntryTable.convertRowIndexToModel(warrantEntryTable.getSelectedRow());
					selectedNalogEntry=nalogEntryList.get(rowIndex);
					entryActionButton.setText(messageService.getMessage("organiazation.sector.action.save"));
					if (selectedNalogEntry.getType().equals(NalogEntryType.DOLZI))
						debtDemandComboBox.setSelectedIndex(0);
					else
						debtDemandComboBox.setSelectedIndex(1);
					amountField.setText(selectedNalogEntry.getAmount()+"");
					documentTypeComboBox.setSelectedIndex(0);
					documentDate.setDate(selectedNalogEntry.getDocumentDate());
					int indexKomintent=0;
					for (Komintent komintent:komintentList){
						if (komintent.getCode().equals(selectedNalogEntry.getKomintent().getCode())){
								comintentComboBox.setSelectedIndex(indexKomintent);
								break;
						}
						indexKomintent++;
					}
					int indexOrganizationSector=0;
					for (OrganizationSector organizationSector:organizationSectorList){
						if (organizationSector.getCode().equals(selectedNalogEntry.getOrganizationSector().getCode())){
							organizationSectorComboBox.setSelectedIndex(indexOrganizationSector);
							break;
						}
						indexOrganizationSector++;	
					}
					accountField.setText(selectedNalogEntry.getKonto()+"");
					descriptionField.setText(selectedNalogEntry.getDescription());
					documentNumberField.setText(selectedNalogEntry.getDocumentNumber());
					currencyDateField.setDate(selectedNalogEntry.getValuta());
					warrantEntryPanel.setVisible(true);
				}
			}
		});
		
		changeWarrantNameButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				if (newWarrantNameField.getText().equals("")){
					JOptionPane.showMessageDialog(component, messageService.getMessage("warrant.no.new.name"),"Error", JOptionPane.ERROR_MESSAGE);
				}
				else {
					DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
					List<StringEntry> properties = new ArrayList<StringEntry>(1);
					properties.add(new StringEntry("base.number", "'" + newWarrantNameField.getText()+ "'"));
					properties.add(new StringEntry("base.date", "'" + dateFormat.format(warrantDate.getDate())+"'"));
					
					// result
					List<Nalog> result = modelService.findByProperties(Nalog.class, null, properties);
					if (!CollectionUtils.isEmpty(result)){
						JOptionPane.showMessageDialog(component, messageService.getMessage("warant.error.existing.name"),"Error", JOptionPane.ERROR_MESSAGE);
						return;
					}
					selectedNalog.setNumber(newWarrantNameField.getText());
					try {
						modelService.update(selectedNalog);
						warrantNumberField.setText(selectedNalog.getNumber());
						JOptionPane.showMessageDialog(component, messageService.getMessage("warrant.save.name.successful"),"", JOptionPane.INFORMATION_MESSAGE);
						
					} catch (Exception ex){
						JOptionPane.showMessageDialog(component, messageService.getMessage("warrant.error.new.name"),"Error", JOptionPane.ERROR_MESSAGE);
						modelService.refresh(selectedNalog);
					}
				}
					
			}
		});
	}

	//WarrantEntryTablePanel
	private javax.swing.JPanel warrantEntryTablePanel;
	private javax.swing.JScrollPane warrantEntryScrollPane;
	private javax.swing.JTable warrantEntryTable;
	private DefaultTableModel warrantEntryTableModel;
	private javax.swing.JLabel isEqualAmountLabel;
	private javax.swing.JLabel isEqualAmountDataLabel;
	private javax.swing.JLabel debtInfoLabel;
    private javax.swing.JLabel debtInfoSumLabel;
    private javax.swing.JLabel demandInfoLabel;
    private javax.swing.JLabel demandInfoSumLabel;
    private javax.swing.JLabel differenceInfoLabel;
    private javax.swing.JLabel differenceInfoDataLabel;
    private List<NalogEntry> nalogEntryList;
	@SuppressWarnings("all")
	private void initWarrantEntryTablePanel(){
        //Adding the components of the WarrantEntryTablePanel
		warrantEntryTablePanel = new javax.swing.JPanel();
        warrantEntryTablePanel.setBorder(BorderFactory.createTitledBorder(messageService.getMessage("warrant.inputed.entries")));
        warrantEntryScrollPane = new javax.swing.JScrollPane();
        warrantEntryTable = new javax.swing.JTable();
        warrantEntryTable.setAutoCreateRowSorter(true);  
        warrantEntryTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        warrantEntryTableModel=new javax.swing.table.DefaultTableModel(
                new Object [][] {
                },
                new String [] {
                    messageService.getMessage("warrant.table.number.short"), messageService.getMessage("warrant.table.debt.demand.short"),
                    messageService.getMessage("warrant.table.amount"),messageService.getMessage("warrant.table.account.short"),
                    messageService.getMessage("warrant.table.description.short"),messageService.getMessage("warrant.table.document.number.short"),
                    messageService.getMessage("warrant.table.document.date.short"),messageService.getMessage("warrant.table.document.date.value.short"),
                    messageService.getMessage("warrant.table.document.organization.sector.short"),messageService.getMessage("warant.table.comintent")
                }
            ) {
                Class[] types = new Class [] {
                    java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
                };
                boolean[] canEdit = new boolean [] {
                    false, false, false, false, false, false, false, false, false, false
                };

                public Class getColumnClass(int columnIndex) {
                    return types [columnIndex];
                }

                public boolean isCellEditable(int rowIndex, int columnIndex) {
                    return canEdit [columnIndex];
                }
            };
            warrantEntryTable.setModel(warrantEntryTableModel);
            warrantEntryScrollPane.setViewportView(warrantEntryTable);
        isEqualAmountLabel = new javax.swing.JLabel(messageService.getMessage("warrant.is.equal.amount"));
        isEqualAmountDataLabel = new javax.swing.JLabel(messageService.getMessage("warrant.equal"));
        isEqualAmountDataLabel.setForeground(new Color(0,255,0));
        debtInfoLabel = new javax.swing.JLabel(messageService.getMessage("warrant.debt"));
        debtInfoSumLabel = new javax.swing.JLabel("0.0");
        demandInfoLabel = new javax.swing.JLabel(messageService.getMessage("warrant.demand"));
        demandInfoSumLabel = new javax.swing.JLabel("0.0");
        differenceInfoLabel = new javax.swing.JLabel(messageService.getMessage("warrant.difference"));
        differenceInfoDataLabel = new javax.swing.JLabel("0.0");
	}
   
	public void initComponents() {
		// title
		setTitle(messageService.getMessage("inputFinancialOrder.title"));
		//Size
		this.setSize(AppConstants.MainFrame.WIDTH, AppConstants.MainFrame.HEIGHT);
		//Maximize
		try {
			this.setMaximum(true);
		} catch (PropertyVetoException e) {}
		catch (NullPointerException n){}
		
		this.setLayout(null);
		//Components
		
		initWarrantPanel();

		initWarrantEntryPanel();
		
		initActionPanel();
		
		initWarrantEntryTablePanel();
        
        /* Layout of the warrantEntryPanel and WarrantEntryTablePanel */
        setLayout();
        
        //Add the Panels in the main Internal Frame
        warrantEntryPanel.setVisible(false);
        warrantEntryTablePanel.setVisible(false);
        actionPanel.setVisible(false);
        
		clearData();
		//Draw the main InternalFrame
		this.setVisible(true);
		
		component.add(this);
	}
	

	private Year getYear(){
		Year year=new Year();
		try {
			year=modelService.findById(Year.class, Long.parseLong(warrantYear.getText()));
			if (year==null) {
				year=new Year();
				year.setOrganization(modelService.findAll(Organization.class).get(0));
				year.setYear(Long.parseLong(warrantYear.getText()));
				modelService.update(year);
			}
		}
		catch (Exception ex){
		}
		return year;
	}
	
	@SuppressWarnings("unchecked")
	private NalogEntry getFilledNalogEntry(Nalog nalog){
		NalogEntry nalogEntry=new NalogEntry();
		if (((String)debtDemandComboBox.getSelectedItem()).equals(messageService.getMessage("warrant.debt")))
			nalogEntry.setType(NalogEntryType.DOLZI);
		else
			nalogEntry.setType(NalogEntryType.POBARUVA);
		nalogEntry.setNalog(nalog);
		nalogEntry.setAmount(BigDecimal.valueOf(Double.parseDouble(amountField.getText())));
//		nalogEntry.setDocument(null);
		nalogEntry.setDocumentDate(documentDate.getDate());
		nalogEntry.setKomintent(((ComboBoxElement<Komintent>)comintentComboBox.getSelectedItem()).getKey());
		nalogEntry.setOrganizationSector(((ComboBoxElement<OrganizationSector>)organizationSectorComboBox.getSelectedItem()).getKey());
		String kontoClass=accountField.getText().substring(0,1);
		String kontoGroup=accountField.getText().substring(1,2);
		String kontoSynthetic=accountField.getText().substring(2,3);
		String kontoAnalytic=accountField.getText().substring(3,accountField.getText().length());
		Konto konto=kontoService.findKonto(kontoClass, kontoGroup, kontoSynthetic, kontoAnalytic);
		nalogEntry.setKonto(konto);
		nalogEntry.setDescription(descriptionField.getText());
		nalogEntry.setDocumentNumber(documentNumberField.getText());
		nalogEntry.setValuta(currencyDateField.getDate());
//		nalogEntry.setEntryDate(warrantDate.getDate());
		return nalogEntry;
	}
	
	private Nalog getFilledNalog(){
		Nalog nalog=new Nalog();
		DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
		try {
			nalog.setDate(dateFormat.parse(dateFormat.format(warrantDate.getDate())));
		} 
		catch (Exception ex) {}
		Year year=getYear();
		nalog.setYear(year);
		nalog.setNumber(warrantNumberField.getText());
		return nalog;
	}

	private void refreshTableData(Nalog nalog){
	
		// search properties
		List<StringEntry> properties = new ArrayList<StringEntry>(1);
		properties.add(new StringEntry("base.nalog", "'" + nalog.getId()+ "'"));
		
		// result
		nalogEntryList = modelService.findByProperties(NalogEntry.class, null, properties);
		warrantEntryTableModel.getDataVector().removeAllElements();
		warrantEntryTable.setAutoCreateRowSorter(true);
		int br=1;
		Double debtTotal=0D,demandTotal=0D;
		for (NalogEntry nalogEntry:nalogEntryList){
			Vector<String> row = new Vector<String>();
			row.add(br+"");
			br++;
			row.add(nalogEntry.getType()+"");
			row.add(nalogEntry.getAmount()+"");
			row.add(nalogEntry.getKonto()+"");
			row.add(nalogEntry.getDescription());
			row.add(nalogEntry.getDocumentNumber());
			row.add(nalogEntry.getDocumentDate()+"");
			row.add(nalogEntry.getValuta()+"");
			row.add(nalogEntry.getOrganizationSector().getDescription());
			row.add(nalogEntry.getKomintent().getName());
			warrantEntryTableModel.addRow(row);
			if (nalogEntry.getType().equals(NalogEntryType.DOLZI))
				debtTotal+=nalogEntry.getAmount().doubleValue();
			else
				demandTotal+=nalogEntry.getAmount().doubleValue();
		}
		debtInfoSumLabel.setText(debtTotal.toString());
		demandInfoSumLabel.setText(demandTotal.toString());
		differenceInfoDataLabel.setText((debtTotal-demandTotal)+"");
		if (debtTotal.equals(demandTotal)){
			isEqualAmountDataLabel.setText(messageService.getMessage("warrant.equal"));
	        isEqualAmountDataLabel.setForeground(new Color(0,255,0));
		}
		else {
			isEqualAmountDataLabel.setText(messageService.getMessage("warrant.notequal"));
	        isEqualAmountDataLabel.setForeground(new Color(255,0,0));
		}
		
	}
	
	private void clearData(){
		comintentComboBox.setSelectedIndex(0);
		organizationSectorComboBox.setSelectedIndex(0);
		debtDemandComboBox.setSelectedIndex(0);
		amountField.setText("0.0");
		documentDate.setDate(null);
		accountField.setText("");
		descriptionField.setText("");
		documentNumberField.setText("");
		currencyDateField.setDate(null);
	}
	
	
	private void setLayout(){
		javax.swing.GroupLayout warrantPanelLayout = new javax.swing.GroupLayout(warrantPanel);
        warrantPanel.setLayout(warrantPanelLayout);
        warrantPanelLayout.setHorizontalGroup(
            warrantPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(warrantPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(warrantYearLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(warrantYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(requiredLabelWarrant1, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(warrantNumberLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(warrantNumberField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(requiredLabelWarrant2)
                .addGap(18, 18, 18)
                .addComponent(warrantDateLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warrantDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(requiredLabelWarrant3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(showEntriesButton)
                .addContainerGap(45, Short.MAX_VALUE))
        );
        warrantPanelLayout.setVerticalGroup(
            warrantPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(warrantPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(warrantPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(warrantYearLabel)
                    .addComponent(warrantYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(requiredLabelWarrant1)
                    .addComponent(warrantNumberLabel)
                    .addComponent(warrantNumberField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(requiredLabelWarrant2)
                    .addComponent(warrantDateLabel)
                    .addComponent(warrantDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(requiredLabelWarrant3)
                    .addComponent(showEntriesButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        javax.swing.GroupLayout warrantEntryPanelLayout = new javax.swing.GroupLayout(warrantEntryPanel);
        warrantEntryPanel.setLayout(warrantEntryPanelLayout);
        warrantEntryPanelLayout.setHorizontalGroup(
            warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(warrantEntryPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, warrantEntryPanelLayout.createSequentialGroup()
                        .addComponent(organizationSectorLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(organizationSectorComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(warrantEntryPanelLayout.createSequentialGroup()
                        .addComponent(comintentLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(comintentComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(warrantEntryPanelLayout.createSequentialGroup()
                        .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(amountLabel)
                            .addComponent(documentTypeLabel)
                            .addComponent(debtDemandLabel)
                            .addComponent(documentDateLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(documentTypeComboBox, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(amountField)
                            .addComponent(debtDemandComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(documentDate, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(warrantEntryPanelLayout.createSequentialGroup()
                        .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(requiredLabel)
                            .addComponent(requiredLabel2, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGap(21, 21, 21)
                        .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(documentNumberLabel)
                            .addComponent(currencyDateLabel)
                            .addComponent(descriptionLabel)
                            .addComponent(accountLabel)))
                    .addComponent(requiredLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(entryActionButton)
                    .addGroup(warrantEntryPanelLayout.createSequentialGroup()
                        .addComponent(accountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(requiredLabel1))
                    .addComponent(documentNumberField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(currencyDateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(descriptionField, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(263, Short.MAX_VALUE))
        );
        warrantEntryPanelLayout.setVerticalGroup(
            warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(warrantEntryPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(debtDemandLabel)
                    .addComponent(debtDemandComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(accountLabel)
                    .addComponent(accountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(requiredLabel)
                    .addComponent(requiredLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(amountLabel)
                    .addComponent(amountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(descriptionLabel)
                    .addComponent(descriptionField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(requiredLabel2))
                .addGap(10, 10, 10)
                .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(documentTypeLabel)
                    .addComponent(documentTypeComboBox)
                    .addComponent(documentNumberLabel)
                    .addComponent(documentNumberField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(documentDateLabel)
                    .addComponent(documentDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(currencyDateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(currencyDateLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comintentLabel)
                    .addComponent(comintentComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(requiredLabel3)
                    .addComponent(entryActionButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(warrantEntryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(organizationSectorLabel)
                    .addComponent(organizationSectorComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
        javax.swing.GroupLayout warrantEntryTablePanelLayout = new javax.swing.GroupLayout(warrantEntryTablePanel);
        warrantEntryTablePanel.setLayout(warrantEntryTablePanelLayout);
        warrantEntryTablePanelLayout.setHorizontalGroup(
            warrantEntryTablePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(warrantEntryTablePanelLayout.createSequentialGroup()
                .addGroup(warrantEntryTablePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(warrantEntryScrollPane)
                    .addGroup(warrantEntryTablePanelLayout.createSequentialGroup()
                        .addGap(74, 74, 74)
                        .addComponent(isEqualAmountLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(isEqualAmountDataLabel)
                        .addGap(18, 18, 18)
                        .addComponent(debtInfoLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(debtInfoSumLabel)
                        .addGap(28, 28, 28)
                        .addComponent(demandInfoLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(demandInfoSumLabel)
                        .addGap(18, 18, 18)
                        .addComponent(differenceInfoLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(differenceInfoDataLabel)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        warrantEntryTablePanelLayout.setVerticalGroup(
            warrantEntryTablePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(warrantEntryTablePanelLayout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(warrantEntryScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(warrantEntryTablePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(isEqualAmountLabel)
                    .addComponent(isEqualAmountDataLabel)
                    .addComponent(debtInfoLabel)
                    .addComponent(debtInfoSumLabel)
                    .addComponent(demandInfoLabel)
                    .addComponent(demandInfoSumLabel)
                    .addComponent(differenceInfoLabel)
                    .addComponent(differenceInfoDataLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        javax.swing.GroupLayout actionPanelLayout = new javax.swing.GroupLayout(actionPanel);
        actionPanel.setLayout(actionPanelLayout);
        actionPanelLayout.setHorizontalGroup(
            actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(actionPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(addEntryButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(modifyEntryButton)
                .addGap(42, 42, 42)
                .addComponent(newWarrantNameLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(newWarrantNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(changeWarrantNameButton)
                .addContainerGap(84, Short.MAX_VALUE))
        );
        actionPanelLayout.setVerticalGroup(
            actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(actionPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(addEntryButton)
                    .addComponent(modifyEntryButton)
                    .addComponent(changeWarrantNameButton)
                    .addComponent(newWarrantNameLabel)
                    .addComponent(newWarrantNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(warrantEntryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(warrantPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(actionPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(warrantEntryTablePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(warrantPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addComponent(warrantEntryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(actionPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(warrantEntryTablePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
        );
	}
}
